using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using XLua;

public class GameHome : MonoBehaviour
{
    Text message;
    LuaEnv luaEnv;
    ICallLua callLua;
    // Start is called before the first frame update
    void Start()
    {
        message = GameObject.Find("Message").GetComponent<Text>();
        message.text = "Hello HybridCLR";
        luaEnv = new LuaEnv();
        luaEnv.DoString("require 'Main'");
        callLua = luaEnv.Global.Get<ICallLua>("CallLua");
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void OnClick()
    {
        if(callLua != null)
        {
            callLua.Change(message);
        }
    }

    void OnDestroy()
    {
        luaEnv.Dispose();

    }    
}

[CSharpCallLua]
public interface ICallLua
{
    void Change(Text text);
}
